package me.olook.netease.song.rank.biz.impl;

import me.olook.netease.song.rank.biz.TimerJobService;
import me.olook.netease.song.rank.entity.TimerJob;
import me.olook.netease.song.rank.mapper.TimerJobJpaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author zhaohw
 * @date 2018-05-24 16:15
 */
@Service
public class TimerJobBizImpl implements TimerJobService {

    @Autowired
    private TimerJobJpaDao timerJobJpaDao;

    @Override
    public Optional<TimerJob> findByNameAndGroup(String name , String group) {
        TimerJob timerJob = new TimerJob();
        timerJob.setJobName(name);
        timerJob.setJobGroup(group);
        Example<TimerJob> example = Example.of(timerJob);
        return timerJobJpaDao.findOne(example);
    }

    @Override
    public List<TimerJob> findAll() {
        return timerJobJpaDao.findAll();
    }
}
